package com.ms.p2p.service.impl;


import com.ms.p2p.dao.LinkDao;
import com.ms.p2p.entity.content.Link;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LinkServiceImpl{
	// 下面是类别的操作

	@Autowired
	LinkDao linkDao;


	@Cacheable(value = "link")
	public List<Link> getList() {
		return linkDao.getList();

	}

	@Cacheable(value = "link", key = "'link'+#id")
	public Link getOne(int id) {
		return  linkDao.get(id+"");

	}

	@CacheEvict(value = "link", allEntries = true)
	public int insert(Link map) {
		return linkDao.insert(map);


	}

	@CacheEvict(value = "link", allEntries = true)
	public int update(Link map) {
		return linkDao.update(map);

	}

	@CacheEvict(value = "link", allEntries = true)
	public int del(int id) {
		return linkDao.deleteById(id);
	}

}
